#include<iostream>
#include<cstring>
using namespace std;


#define maxn 1000

int sum[maxn]; // 数值为1的水平位置的所有节点的权重之和

void process(int pos){
    int l,r;
    cin >> l;
    if(l!=-1){
        sum[pos-1]+=l;
        process(pos-1);
    }
    cin >> r;
    if(r!=-1){
        sum[pos+1]+=r;
        process(pos+1);
    }
}

int main(){

    int root;
    int rnd=1;
    int f=0;
    while(cin >> root && root>0){
        memset(sum,0,sizeof(sum));
        int root_pos = maxn/2;
        int i=0;
        sum[root_pos] += root;
        process(root_pos);

        cout<<"Case "<<rnd++<<":"<<endl;
        while(sum[i]==0) i++;
        int first=0;
        while(sum[i]){
            if(first++) cout<<" ";
            cout<<sum[i++];
        }
        cout<<endl<<endl;
    }
    return 0;
}